<template>
  <Card class="cpyszjy-optional-editor" style="height:900px">
    <div class="optional-editor-container">
      <div class="option-item">
        <v-optional-editor label="产品大类" :labelValue="productTypeName" v-model="productTypeName">
        </v-optional-editor>
      </div>
      <div class="option-item">
        <v-optional-editor label="产品" :labelValue="product" v-model="product">
        </v-optional-editor>
      </div>
      <div class="option-item">
        <v-optional-editor label="资金源" :labelValue="fund" v-model="fund">
        </v-optional-editor>
      </div>
      <div class="option-item">
        <v-optional-editor v-if="type=='1'" label="优先级" :labelValue="prior" v-model="prior">
        </v-optional-editor>
        <v-optional-editor v-if="type=='2'" label="优先级" :labelValue="prior" :type="'input'" v-model="prior">
        </v-optional-editor>
      </div>
      <div class="option-item">
        <v-optional-editor v-if="type=='1'" label="状态" :labelValue="status" v-model="status">
        </v-optional-editor>
        <v-optional-editor v-if="type=='2'" label="状态" :labelValue="status" :type="'select'" v-model="status" :selectData="statusList">
        </v-optional-editor>
      </div>
      <!-- <div class="option-item" v-if="type==0">
        <v-optional-editor label="资金年华利率" labelValue="辅导4234费" :type="'select'" v-model="gdh"
                           :selectData="optionsData">
        </v-optional-editor>
      </div> -->
    </div>
    <div class="other-info" v-if="type!='0'">
      <div class="info-item">
        <span>最后更新时间</span>
        <span>2017-04-21 10:45:41.0</span>
      </div>
      <div class="info-item">
        <span>最后更新用户</span>
        <span>zhangzelin</span>
      </div>
    </div>
    <div class="bottom-btn" v-if="type=='2'">
      <v-button type="primary" size="small" @on-click="conf">确定</v-button>
      <v-button type="warn" size="small" @on-click="handleGoBack">返回</v-button>
    </div>
    <div class="bottom-btn" v-else>
      <v-button type="primary" size="small" @on-click="handleRouterGo()">编辑</v-button>
      <v-button type="warn" size="small" @on-click="handleGoBack">返回</v-button>
    </div>
  </Card>
</template>
<script>
import routeMixin from '../../../mixins/routeMixin'
import api from '@/api'
export default {
  mixins: [routeMixin],
  data () {
    return {
      productTypeName: '',
      product: '',
      fund: '',
      prior: '',
      status: '',
      statusList: [
        {
          value: '异常',
          label: '异常'
        }, {
          value: '正常',
          label: '正常'
        }
      ]
    }
  },
  created () {
    var vm = this
    var param = JSON.parse(vm.$route.query.param)
    vm.productTypeName = param.productTypeName
    vm.product = param.productName
    vm.fund = param.fundName
    vm.prior = param.level + ''
    vm.status = param.status
  },
  computed: {
    type () {
      return this.$route.query.type
    }
  },
  mounted () {
  },
  methods: {
    handleRouterGo () {
      var vm = this
      this.$router.push({ name: 'cpyszjyeditor', query: { param: vm.$route.query.param, type: '2' } })
    },
    conf () {
      var vm = this
      var param = JSON.parse(vm.$route.query.param)
      var tmp = ''
      if (vm.status === '正常') {
        tmp = '0'
      } else if (vm.status === '异常') {
        tmp = '1'
      }
      var params = {
        id: param.id,
        level: vm.prior,
        status: tmp
      }
      api.editProductMappingFund(params).then(re => {
        if (re.data.code === 'success') {
          this.$router.push('cpyszjy')
        }
      }).catch(er => { })
    }
  },
  props: {},
  watch: {
    $route (val) {
    }
  }
}
</script>

<style lang="less">
.cpyszjy-optional-editor {
}
</style>
